package rd.system.home {
	
	import com.sff.manager.StyleManager;
	import com.sff.site.utils.Link;
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.external.ExternalInterface;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	/**
	 * ...
	 * @author cuong.tran@rdsystem.org
	 */
	public class Footer extends Sprite {
		
		public var mcLinkedIn:MovieClip;
		public var mcFaceBook:MovieClip;
		public var mcBG:MovieClip;
		public var txtCopyRight:TextField;
		
		private var xmlData:XML;
		
		public function Footer() {
			mcLinkedIn.buttonMode = true;
			mcLinkedIn.addEventListener(MouseEvent.CLICK, onClickLinkedInHandler);
			
			mcFaceBook.buttonMode = true;
			mcFaceBook.addEventListener(MouseEvent.CLICK, onClickFaceBookHandler);
		}
		
		private function onClickFaceBookHandler(evt:MouseEvent):void {
			var link:Link = new Link(xmlData.link.(@id == 'facebook')[0]);
			link.navigate();
		}
		
		private function onClickLinkedInHandler(evt:MouseEvent):void {
			var link:Link = new Link(xmlData.link.(@id == 'linkedin')[0]);
			link.navigate();	
		}
		
		public function setData(xml:XML, sm:StyleManager):void {
			xmlData = xml;
			
			txtCopyRight.autoSize = TextFieldAutoSize.LEFT;
			txtCopyRight.text = xmlData.label.(@id == 'copyright').toString();
			sm.applyStyle(txtCopyRight, 'titleStyle');
			
			txtCopyRight.y = mcBG.height / 2 - txtCopyRight.textHeight / 2 - 2;
		}
		
		public function resize(newWidth:Number, newHeight:Number):void {			
			mcBG.width = newWidth + 2;			
			
			mcLinkedIn.x = newWidth - mcLinkedIn.width - 5;
			mcFaceBook.x = mcLinkedIn.x - mcFaceBook.width - 5;
		}
		
		override public function get height():Number {
			return mcBG.height - 1;
		}
	}
}